import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import {JVxeTypes,JVxeColumn} from '/@/components/jeecg/JVxeTable/types'
import { getWeekMonthQuarterYear } from '/@/utils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '采购单编号',
    align:"center",
    dataIndex: 'orderSn'
   },
   {
    title: '订购人',
    align:"center",
    dataIndex: 'name'
   },
   {
    title: '总金额',
    align:"center",
    dataIndex: 'money'
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '采购单编号',
    field: 'orderSn',
    component: 'Input',
  },
  {
    label: '订购人',
    field: 'name',
    component: 'Input',
  },
  {
    label: '总金额',
    field: 'money',
    component: 'Input',
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];
//子表单数据
export const defaAaOrderAddressFormSchema: FormSchema[] = [
  {
    label: '地址',
    field: 'address',
    component: 'Input',
  },
  {
    label: '姓名',
    field: 'name',
    component: 'Input',
  },
  {
    label: '手机号码',
    field: 'mobile',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: false},
                 { pattern: /^1[3456789]\d{9}$/, message: '请输入正确的手机号码!'},
          ];
     },
  },
  {
    label: '邮箱',
    field: 'email',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: false},
                 { pattern: /^([\w]+\.*)([\w]+)@[\w]+\.\w{3}(\.\w{2}|)$/, message: '请输入正确的电子邮件!'},
          ];
     },
  },
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];
//子表表格配置
export const defaAaOrderProductColumns: JVxeColumn[] = [
    {
      title: '水果',
      key: 'shuiguo',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '单价',
      key: 'price',
      type: JVxeTypes.inputNumber,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '数量',
      key: 'num',
      type: JVxeTypes.inputNumber,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '合计',
      key: 'total',
      type: JVxeTypes.inputNumber,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
  ]


// 高级查询数据
export const superQuerySchema = {
  orderSn: {title: '采购单编号',order: 0,view: 'text', type: 'string',},
  name: {title: '订购人',order: 1,view: 'text', type: 'string',},
  money: {title: '总金额',order: 2,view: 'text', type: 'string',},
  //子表高级查询
  defaAaOrderProduct: {
    title: '水果明细',
    view: 'table',
    fields: {
        shuiguo: {title: '水果',order: 0,view: 'text', type: 'string',},
        price: {title: '单价',order: 1,view: 'number', type: 'number',},
        num: {title: '数量',order: 2,view: 'number', type: 'number',},
        total: {title: '合计',order: 3,view: 'number', type: 'number',},
    }
  },
  defaAaOrderAddress: {
    title: '收货地址',
    view: 'table',
    fields: {
        address: {title: '地址',order: 0,view: 'text', type: 'string',},
        name: {title: '姓名',order: 1,view: 'text', type: 'string',},
        mobile: {title: '手机号码',order: 2,view: 'text', type: 'string',},
        email: {title: '邮箱',order: 3,view: 'text', type: 'string',},
    }
  },
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
// 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}